Method for controlling data write operation of a mass storage device

ABSTRACT

A method for controlling data write operation of a mass storage device is provided. The mass storage device has a controller and a memory unit. The method includes connecting the mass storage device to a host device, and receiving a voltage provided from the host device; sensing and monitoring whether the voltage is lower than a first predefined voltage; writing data to the mass storage device with a first frequency when the sensed voltage is higher than the first predefined voltage; and writing data to the mass storage device with a second frequency when the sensed voltage is lower than the first predefined voltage, wherein the second frequency is adjusted by decreasing the first frequency.

BACKGROUND

1. Technical Field

The present invention relates to a method for controlling data-writeoperation of amass storage device, and more particularly, to a methodfor controlling data-write operation of a mass storage device accordingto sensed input voltage of a memory unit.

2. Description of the Conventional Art

As related technology keeps improving, various types of mass storagedevices such as hard drives or flash drives are developed for storingdata according to requirements. Please refer to FIG. 1. FIG. 1 is adiagram showing a mass storage device 100 of the conventional art. Asshown in FIG. 1, the mass storage device 100 of the conventional artcomprises a memory unit 110 (such as a flash memory unit), and acontroller 120. The memory unit 110 is utilized for storing data, andthe memory unit 110 is powered by an input voltage Vi(generally 3.3volt) provided from a host device 200. The controller 120 is utilizedfor controlling data access of the memory unit 110, for example, thecontroller 120 can perform operations of writing data into the memoryunit 110, reading data stored in the memory unit 110, and etc.

Generally, a flash memory unit works normally when working voltage ofthe flash memory unit is between 3.3 volt and 3.5 volt. When the workingvoltage of the flash memory unit is between 2.7 volt and 3.3 volt, theflash memory still can work, but may cause some data loss. When theworking voltage of the flash memory unit is lower than 2.7 volt, theflash memory unit can not work normally, so as to significantly increasepossibility of data loss.

Please refer to FIG. 2, and refer to FIG. 1 as well. FIG. 2 is a diagramillustrating data write operation of the mass storage device 100 ofFIG. 1. When the controller 120 performs data write operation, thecontroller 120 writes data into the memory unit 110 at a predetermineddata write frequency, and the predetermined data write frequency is afixed frequency. During the data write operation, when the host device200 provides an unstable voltage to the mass storage device 100, andcauses the input voltage Vi of the memory unit 110 to drop to a voltagelevel lower than 2.7 volt, the memory unit 110 may not work normally towrite data due to insufficient voltage level, such that the data writteninto the memory unit 110 between time T1 and time T2 may be lost. Themass storage device 100 of the conventional art does not have anyprotection mechanism to prevent the above situation of data loss whenthe input voltage Vi of the memory unit 110 is unstable.

SUMMARY

The present invention provides a method for controlling data writeoperation of a mass storage device. The mass storage device has acontroller and a memory unit. The method comprises connecting the massstorage device to a host device, and receiving a voltage provided fromthe host device or from an internal power supply unit; sensing andmonitoring whether the voltage is lower than a first predefined voltage;writing data to the mass storage device with a first frequency when thesensed voltage is higher than the first predefined voltage; and writingdata to the mass storage device with a second frequency when the sensedvoltage is lower than the first predefined voltage, wherein the secondfrequency is adjusted by decreasing the first frequency.

The present invention further provides amass storage device. The massstorage device comprises a memory unit, for storing data; a sense unit,for sensing an input voltage of the memory unit; and a controller,coupled to the memory unit and the sense unit for adjusting a data writefrequency of the memory unit according to sensed input voltage of thememory unit. The input voltage is selectively provided from a hostdevice through a connecting interface, or from an internal power supplyunit of the mass storage device.

These and other objectives of the present invention will no doubt becomeobvious to those of ordinary skill in the art after reading thefollowing detailed description of the preferred embodiment that isillustrated in the various figures and drawings.

BRIEF DESCRIPTION OF THE DRAWINGS

FIG. 1 is a diagram showing a mass storage device of the prior art.

FIG. 2 is a diagram illustrating data write operation of the massstorage device of FIG. 1.

FIG. 3A is a diagram showing a mass storage device of the presentembodiment.

FIG. 3B is a diagram showing another mass storage device of the presentembodiment.

FIG. 4 is a diagram illustrating an embodiment of the controllerperforming the protection mechanism when the input voltage is unstable.

FIG. 5 is a diagram illustrating another embodiment of the controllerperforming the protection mechanism when the input voltage is unstable.

FIG. 6 is a flowchart of the method of the present embodiment forcontrolling data write operation of the mass storage device.

DETAILED DESCRIPTION

Please refer to FIG. 3A. FIG. 3A is a diagram showing a mass storagedevice 300 of the preferred embodiment of the present invention. Asshown in FIG. 3A, the mass storage device 300A comprises a memory unit310, a sense unit 330, and a controller 320. In convention, the massstorage 300A can be coupled to the host device 200 through a connectinginterface 340A, ex. USB, to receive a controlling command and workingvoltage provided from the host device 200, and the connecting interface340A is coupled to the controller 320 of the mass storage 300. Thememory unit 310 can be flash memory for storing data, and the memoryunit 310 is coupled to the controller 320 and powered by an inputvoltage Vi (such as 3.3 volt) provided from a host device 200. The senseunit 330 is utilized for sensing the input voltage Vi of the memory unit310. In another preferred embodiment of the present invention, the senseunit 330 can be integrated into the controller 320 such as being a partof the controller 320. The sense unit 330 can be an analog-to-digitalconverter for converting sensed input voltage from an analog signal to adigital signal DS, and the sense unit 330 can further transmit thedigital signal DS to the controller 320 for notifying the sensed inputvoltage to the controller 320. The controller 320 is coupled to thesense unit 330 and the memory unit 310, and utilized for controllingdata access of the memory unit 310. For example, the controller 320 canperform operations of writing data into the memory unit 310, readingdata stored in the memory unit 310, and etc. according to thecontrolling command from the host device 200. During data writeoperation, the controller 320 can provide a protection mechanismaccording to the digital signal DS transmitted from the sense unit 330,in order to prevent the situation of data loss when the input voltage Viof the memory unit 310 is unstable.

Please refer to FIG. 3B. FIG. 3B is a diagram showing another massstorage device 300B of another preferred embodiment of the presentinvention. Comparing to the mass storage device 300A of FIG. 3A, themass storage device 300B further comprises a power supply unit 350,which is coupled to the controller 330 and the memory unit 310. Thepower supply unit 350 may be a battery or a continuous power supply,which may store the natural energy into a battery (such as a solarbattery). In this preferred embodiment, the input voltage Vi (such as3.3 volt) is provided from the power supply unit 350, and the hostdevice 200 may only provides command and data for writing to the memoryunit 310 through the connecting interface 340B, which may be a wirelessconnecting interface ex. WiFi, Bluetooth etc., of the mass storagedevice 300B. The sense unit 330 is utilized for sensing the inputvoltage Vi provided from the power supply unit 350. Similar to thepreferred embodiment described in the FIG. 3A, the sense unit 330 can beintegrated into the controller 320 such as being a part of thecontroller 320, and can be an analog-to-digital converter for convertingsensed input voltage from an analog signal to a digital signal DS.

For example, please refer to FIG. 4, FIG. 4 is a diagram illustrating anembodiment of the controller performing the protection mechanism whenthe input voltage is unstable. As shown in FIG. 4, the data writeoperation of the mass storage device 300 can be divided into severalstages. In stage I, the input voltage Vi provided from the host deviceis above a first predefined voltage (such as 3.0 volt), the controller320 determines the input voltage Vi is stable according to the digitalsignal DS transmitted from the sense unit 330, and controls a data writefrequency of the memory unit 310 at a predetermined write frequency fw.The first predefined voltage is the voltage over a level, which can beprovided to the mass storage device 300 for operating normally. When thehost device 200 provides an unstable voltage to the mass storage device300, and causes the input voltage Vi of the memory unit 310 to drop to avoltage level lower than the first predefined voltage, which is in stageII, the controller 320 determines the input voltage Vi is unstableaccording to the digital signal DS transmitted from the sense unit 330,and adjusts the data write frequency of the memory unit 310 at a lowerwrite frequency, ex. 70% of the predetermined data write frequency fw,in order to reduce power consumption of the mass storage device 300(that is for reducing the loading of the host device 200). If the inputvoltage Vi of the memory unit 310 continues to drop to a voltage levellower than a second predefined voltage (such as 2.9 volt), thecontroller 320 determines the input voltage Vi is still unstableaccording to the digital signal DS transmitted from the sense unit 330,and adjusts the data write frequency of the memory unit 310 at anotherlower write frequency, ex. 60% of the predetermined data write frequencyfw, in order to further reduce more power consumption of the massstorage device 300.

When the host device 200 restores to provide a stable input voltage tothe mass storage device 300, the input voltage Vi of the memory unit 310will climb up. When the input voltage Vi of the memory unit 310 climbsup to the voltage level between the first predefined voltage and thesecond predefined voltage, the controller 320 controls the data writefrequency of the memory unit 310 at 70% of the predetermined data writefrequency fw, and when the input voltage Vi of the memory unit 310 keepsclimbing up to the voltage level higher than the first predefinedvoltage, the controller 320 determines the input voltage Vi of thememory unit 310 is back to normal status again, and controls the datawrite frequency of the memory unit 310 back to the predetermined datawrite frequency fw.

It should be noticed that the value of each of the predefined voltageand the corresponding decreasing percentage of the data write frequency,can be set up according to different condition and different apparatus.The basic principle to set up the condition is to satisfy thenotification of lacking input voltage and protection of data writingwhen operating the mass storage apparatus.

According to the above arrangement, the mass storage device 300 in thepreferred embodiment of the present invention can adjust the data writefrequency of the memory unit 310 according to the sensed input voltageof the memory unit 310 in order to reduce loading of the host device200, such that the input voltage Vi of the memory unit 310 can berecovered back to normal status. Therefore, the controller 320 can keepthe input voltage Vi of the memory unit 310 above 2.7 volt forpreventing the situation of data loss when the input voltage Vi of thememory unit 310 is insufficient.

Please refer to FIG. 5, FIG. 5 is a diagram illustrating anotherembodiment of the controller performing the protection mechanism whenthe input voltage is unstable. As shown in FIG. 5, in stage I, the inputvoltage Vi provided from the host device 200 or from the internal powersupply unit 350 is above the first predefined voltage (such as 3.0volt), the controller 320 determines that the input voltage Vi is stableaccording to the digital signal DS transmitted from the sense unit 330,and controls the data write frequency of the memory unit 310 at thepredetermined write frequency fw. When the host device 200 or the powersupply unit 350 provides an unstable voltage to the mass storage device300, and causes the input voltage Vi of the memory unit 310 to drop to avoltage level lower than the first predefined voltage, which is in stageII, the controller 320 determines the input voltage Vi is unstableaccording to the digital signal DS transmitted from the sense unit 330,and controls the data write frequency of the memory unit 310 lower thanthe predetermined data write frequency fw, ex. at 70% of thepredetermined data write frequency fw, in order to reduce powerconsumption of the mass storage device 300. If the input voltage Vi ofthe memory unit 310 continues to drop to a voltage level lower than thesecond predefined voltage (such as 2.9 volt), the controller 320determines the input voltage Vi is still unstable according to thedigital signal DS transmitted from the sense unit 330, and controls thedata write frequency of the memory unit 310 at 60% of the predetermineddata write frequency fw, in order to further reduce more powerconsumption of the mass storage device 300. If the input voltage Vi ofthe memory unit 310 continues to drop to a voltage level lower than athird predefined voltage (such as 2.8 volt), which is in stage III, thecontroller 320 determines the power may be lost very soon according tothe digital signal DS transmitted from the sense unit 330, and executesa flush command to stop writing data from the host device 200 andmeanwhile writing data stored in a cache memory 322 of the controller320 to the memory unit 310, in order to write a complete set of datainto the memory unit 310 before power loss.

In addition, in stage II of FIG. 5, more voltage levels can be set asreference for adjusting the data write frequency of the memory unit 310,and the data write frequency of the memory unit 310 can be adjusted toany other percentage of the predetermined data write frequency accordingto design requirements. Furthermore, the mass storage device 300 canfurther comprise a capacitor C coupled to the memory unit 310, such thatthe capacitor C can provide a temporary backup power for executing theflush command in stage III.

As mentioned in the previous preferred embodiment of the presentinvention, it should be noticed that the value of each of the predefinedvoltage and the corresponding decreasing percentage of the data writefrequency, can be set up according to different conditions and differentapparatus. The basic principle to set up the condition is to satisfy thenotification of lacking input voltage and protection of data writingwhen operating the mass storage apparatus.

Please refer to FIG. 6, which is a flowchart 600 of the method of thepresent embodiment for controlling data write operation of amass storagedevice. The flowchart 600 comprises the following steps of:

Step 610: Control the data write frequency of the memory unit 310 at thefirst frequency;

Step 620: Determine whether the sensed input voltage of the memory unit310 is lower than a first predefined voltage; if yes, go to step 630; ifnot, go to step 610;

Step 630: Control the data write frequency of the memory unit 310 at asecond frequency lower than the first frequency;

Step 640: Determine whether the sensed input voltage of the memory unit310 is higher than the first predefined voltage; if yes, go to step 610;if not, go to step 650;

Step 650: Determine whether the sensed input voltage of the memory unit310 is lower than a second predefined voltage; if yes, go to step 660;if not, go to step 630; and

Step 660: Execute the flush command to stop writing data from the hostdevice 200 and meanwhile writing data stored in the cache memory 322 ofthe controller 320 to the memory unit 310.

Basically, to achieve the same result, the steps of the flowchart 600need not be in the exact order shown and need not be contiguous. Thatis, other steps can be inserted therebetween.

In contrast to the conventional art, the mass storage device of thepreferred embodiment of the present invention can adjust the data writefrequency of the memory unit according to the sensed input voltageprovided from the host device or from the internal power supply unit ofthe memory unit, in order to keep the input voltage of the memory unitabove a certain voltage level for preventing the situation of data losswhen the input voltage of the memory unit is insufficient. In addition,the mass storage device of the preferred embodiment can further executea flush command to write data stored in the cache memory of thecontroller to the memory unit, in order to write a complete set of datainto the memory unit before power loss.

Those skilled in the art will readily observe that numerousmodifications and alterations of the device and method may be made whileretaining the teachings of the invention. Accordingly, the abovedisclosure should be construed as limited only by the metes and boundsof the appended claims.

What is claimed is:
 1. A method for controlling data write operation ofa mass storage device, the mass storage device having a controller and amemory unit, the method comprising: connecting the mass storage deviceto a host device; receiving a command and an input voltage for writingdata to the memory unit; sensing the input voltage to generate a sensingsignal corresponding to the input voltage; determining whether the inputvoltage is lower than a first predefined voltage according to thesensing signal; writing data to the mass storage device with a firstfrequency when the input voltage is higher than the first predefinedvoltage; and writing data to the mass storage device with a secondfrequency when the input voltage is lower than the first predefinedvoltage, wherein the second frequency is adjusted by decreasing thefirst frequency.
 2. The method of claim 1, after the step of writingdata to the mass storage device with the second frequency, furthercomprising steps of: determining whether the input voltage is higherthan the first predefined voltage according to the sensing signal; andwriting data to the mass storage device with the first frequency whenthe input voltage is higher than the first predefined voltage, whereinthe first frequency is adjusted by increasing the second frequency. 3.The method of claim 2, wherein adjusting the second frequency to thefirst frequency is performed by the controller.
 4. The method of claim1, wherein adjusting the first frequency to the second frequency isperformed by the controller.
 5. The method of claim 1 further comprisingsteps of: determining whether the input voltage is lower than a secondpredefined voltage according to the sensing signal; and writing datastored in a cache memory integrated into the controller to the memoryunit when the input voltage is lower than the second predefined voltage.6. The method of claim 1, wherein the input voltage is provided from apower supply unit of the mass storage device.
 7. The method of claim 1,wherein the input voltage is provided from the host device.
 8. A massstorage device, comprising: a memory unit, for storing data; a senseunit, for sensing an input voltage of the memory unit to generate asensing signal corresponding to the input voltage; and a controller,coupled to the memory unit and the sense unit for adjusting a data writefrequency of the memory unit according to the sensing signal; whereinthe controller is configured to adjust the data write frequency of thememory unit from a first frequency to a second frequency which is lowerthan the first frequency when the input voltage of the memory unit islower than a first predefined voltage, and to adjust the data writefrequency of the memory unit from the second frequency to the firstfrequency when the input voltage of the memory unit is higher than thefirst predefined voltage.
 9. The mass storage device of claim 8, whereinthe controller is further configured to execute a flush command to writedata stored in a cache memory of the controller to the memory unit whenthe input voltage of the memory unit is lower than a second predefinedvoltage.
 10. The mass storage device of claim 9 further comprising acapacitor coupled to the memory unit for providing a temporary backuppower for the controller to execute the flush command.
 11. The massstorage device of claim 8, wherein the sensing signal is a digitalsignal.
 12. The mass storage device of claim 11, wherein the controlleris configured to adjust the data write frequency of the memory unitaccording to the digital signal.
 13. A mass storage device comprising: aconnecting interface for receiving a controlling command from a hostdevice; a memory unit, for storing data; a sense unit, for sensing aninput voltage of the memory unit to generate a sensing signalcorresponding to the input voltage; and a controller, coupled to theconnecting interface, the memory unit and the sense unit for adjusting adata write frequency of the memory unit according to the sensing signal,wherein the controller is configured to adjust the data write frequencyof the memory unit from a first frequency to a second frequency which islower than the first frequency when the input voltage of the memory unitis lower than a first predefined voltage, and to adjust the data writefrequency of the memory unit from the second frequency to the firstfrequency when the input voltage of the memory unit is higher than thefirst predefined voltage, and the controller further comprises a cachememory.
 14. The mass storage device of claim 13 further comprising apower supply unit coupled to the controller and the memory unit forsupplying the input voltage of the memory unit.
 15. The mass storagedevice of claim 14, the connecting interface is a wireless connectinginterface.
 16. The mass storage device of claim 13, wherein the inputvoltage of the memory unit is provided from the host device through theconnecting interface.
 17. The mass storage device of claim 13, whereinthe sense unit is integrated with the controller.